package Store;

public class Address {
	private String addressID = "";
	private String accountID = "";
	private String customerID = "";
	private String orderID = "";
	private String street1 = "";
	private String street2 = "";
	private String city = "";
	private String state = "";
	private String zip = "";
	private String country = "";
	private String type = "";
	private static Integer idGenerator = 0;
	
	public Address(){
		
	}
	
	public Address(String street1, String street2, String city, String state, String zip, String country, String type){
		this.setStreet1(street1);
		this.setStreet2(street2);
		this.setCity(city);
		this.setState(state);
		this.setZip(zip);
		this.setCountry(country);
		this.setType(type);
		this.setAccountID(getUniqueAddressID());
	}
	
	public synchronized static String getUniqueAddressID(){
		return ((Integer) idGenerator++).toString();
	}

	public String getStreet1() {
		return street1;
	}

	public void setStreet1(String street1) {
		this.street1 = street1;
	}

	public String getStreet2() {
		return street2;
	}

	public void setStreet2(String street2) {
		this.street2 = street2;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	public String getZip() {
		return zip;
	}

	public void setZip(String zip) {
		this.zip = zip;
	}

	public String getCountry() {
		return country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getType() {
		return type;
	}


	public void setAccountID(String accountID) {
		this.accountID = accountID;
	}


	public String getAccountID() {
		return accountID;
	}


	public void setCustomerID(String customerID) {
		this.customerID = customerID;
	}


	public String getCustomerID() {
		return customerID;
	}


	public void setOrderID(String orderID) {
		this.orderID = orderID;
	}


	public String getOrderID() {
		return orderID;
	}
	
	public boolean commitAddress(){
		try{
			DatabaseAccess accessDatabase = new DatabaseAccess();
			accessDatabase.addItemToDomain(this);
		}
		catch(Exception E)
		{
			return false;
		}
		return true;
	}


	public void setAddressID(String addressID) {
		this.addressID = addressID;
	}


	public String getAddressID() {
		return addressID;
	}
	
	public static Address[] getAddress(String adrID){
		Address[] temp = null;
		DatabaseAccess accessDatabase = new DatabaseAccess();
		temp = accessDatabase.getAddress(adrID);
		return temp;
	}
	
}
